home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / out-of-phase-102-c / OutOfPhase 1.02 Source / OutOfPhase Folder / ClipWarnDialog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  7.9 KB  |  231 lines  |  [TEXT/KAHL]

  1. /* ClipWarnDialog.c */
  2. /*****************************************************************************/
  3. /*                                                                           */
  4. /*    Out Of Phase:  Digital Music Synthesis on General Purpose Computers    */
  5. /*    Copyright (C) 1994  Thomas R. Lawrence                                 */
  6. /*                                                                           */
  7. /*    This program is free software; you can redistribute it and/or modify   */
  8. /*    it under the terms of the GNU General Public License as published by   */
  9. /*    the Free Software Foundation; either version 2 of the License, or      */
  10. /*    (at your option) any later version.                                    */
  11. /*                                                                           */
  12. /*    This program is distributed in the hope that it will be useful,        */
  13. /*    but WITHOUT ANY WARRANTY; without even the implied warranty of         */
  14. /*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
  15. /*    GNU General Public License for more details.                           */
  16. /*                                                                           */
  17. /*    You should have received a copy of the GNU General Public License      */
  18. /*    along with this program; if not, write to the Free Software            */
  19. /*    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              */
  20. /*                                                                           */
  21. /*    Thomas R. Lawrence can be reached at tomlaw@world.std.com.             */
  22. /*                                                                           */
  23. /*****************************************************************************/
  24.  
  25. #include "MiscInfo.h"
  26. #include "Audit.h"
  27. #include "Debug.h"
  28. #include "Definitions.h"
  29.  
  30. #include "ClipWarnDialog.h"
  31. #include "Numbers.h"
  32. #include "DataMunging.h"
  33. #include "Alert.h"
  34. #include "Memory.h"
  35.  
  36.  
  37. /* present a dialog box detailing how much clipping occurred.  the DontTellHowToFix */
  38. /* parameter determines whether the inverse volume correction will be displayed. */
  39. void                                    ClipWarnDialog(long ClippedSampleCount, long TotalSampleCount,
  40.                                                 double MaxExtent, double Correction, MyBoolean DontTellHowToFix)
  41.     {
  42.         char*                                Clipped;
  43.  
  44.         Clipped = IntegerToString(ClippedSampleCount);
  45.         if (Clipped != NIL)
  46.             {
  47.                 char*                                OutOf;
  48.  
  49.                 OutOf = StringToBlockCopy(" out of ");
  50.                 if (OutOf != NIL)
  51.                     {
  52.                         char*                                Concatted;
  53.  
  54.                         Concatted = ConcatBlockCopy(Clipped,OutOf);
  55.                         if (Concatted != NIL)
  56.                             {
  57.                                 char*                                Total;
  58.  
  59.                                 Total = IntegerToString(TotalSampleCount);
  60.                                 if (Total != NIL)
  61.                                     {
  62.                                         char*                                ClipString;
  63.  
  64.                                         ClipString = ConcatBlockCopy(Concatted,Total);
  65.                                         if (ClipString != NIL)
  66.                                             {
  67.                                                 char*                                MiddleInfo;
  68.  
  69.                                                 MiddleInfo = StringToBlockCopy(" samples were clipped, "
  70.                                                     "with a maximum overextent of ");
  71.                                                 if (MiddleInfo != NIL)
  72.                                                     {
  73.                                                         char*                                MostOfIt;
  74.  
  75.                                                         MostOfIt = ConcatBlockCopy(ClipString,MiddleInfo);
  76.                                                         if (MostOfIt != NIL)
  77.                                                             {
  78.                                                                 char*                                OverExtent;
  79.  
  80.                                                                 OverExtent = LongDoubleToString(MaxExtent,6,.1,1e6);
  81.                                                                 if (OverExtent != NIL)
  82.                                                                     {
  83.                                                                         char*                                FinalString;
  84.  
  85.                                                                         FinalString = ConcatBlockCopy(MostOfIt,
  86.                                                                             OverExtent);
  87.                                                                         if (FinalString != NIL)
  88.                                                                             {
  89.                                                                                 char*                                Blurb;
  90.  
  91.                                                                                 if (DontTellHowToFix)
  92.                                                                                     {
  93.                                                                                         Blurb = StringToBlockCopy(".");
  94.                                                                                     }
  95.                                                                                  else
  96.                                                                                     {
  97.                                                                                         Blurb = StringToBlockCopy(".  Set the "
  98.                                                                                             "inverse volume to be greater than ");
  99.                                                                                     }
  100.                                                                                 if (Blurb != NIL)
  101.                                                                                     {
  102.                                                                                         char*                                PutTogether;
  103.  
  104.                                                                                         PutTogether = ConcatBlockCopy(FinalString,Blurb);
  105.                                                                                         if (PutTogether != NIL)
  106.                                                                                             {
  107.                                                                                                 char*                                CorrectionStr;
  108.  
  109.                                                                                                 if (DontTellHowToFix)
  110.                                                                                                     {
  111.                                                                                                         CorrectionStr = AllocPtrCanFail(0,"");
  112.                                                                                                     }
  113.                                                                                                  else
  114.                                                                                                     {
  115.                                                                                                         CorrectionStr = LongDoubleToString(Correction,6,.1,1e6);
  116.                                                                                                     }
  117.                                                                                                 if (CorrectionStr != NIL)
  118.                                                                                                     {
  119.                                                                                                         char*                                Corrected;
  120.  
  121.                                                                                                         Corrected = ConcatBlockCopy(PutTogether,CorrectionStr);
  122.                                                                                                         if (Corrected != NIL)
  123.                                                                                                             {
  124.                                                                                                                 char*                                NullTerminated;
  125.  
  126.                                                                                                             NullTerminated = BlockToStringCopy(Corrected);
  127.                                                                                                             if (NullTerminated != NIL)
  128.                                                                                                                 {
  129.                                                                                                                     if (DontTellHowToFix)
  130.                                                                                                                         {
  131.                                                                                                                             AlertInfo("_",NullTerminated);
  132.                                                                                                                         }
  133.                                                                                                                      else
  134.                                                                                                                         {
  135.                                                                                                                             AlertInfo("_ to eliminate the clipping.",NullTerminated);
  136.                                                                                                                         }
  137.                                                                                                                     ReleasePtr(NullTerminated);
  138.                                                                                                                 }
  139.                                                                                                                 ReleasePtr(Corrected);
  140.                                                                                                             }
  141.                                                                                                         ReleasePtr(CorrectionStr);
  142.                                                                                                     }
  143.                                                                                                 ReleasePtr(PutTogether);
  144.                                                                                             }
  145.                                                                                         ReleasePtr(Blurb);
  146.                                                                                     }
  147.                                                                                 ReleasePtr(FinalString);
  148.                                                                             }
  149.                                                                         ReleasePtr(OverExtent);
  150.                                                                     }
  151.                                                                 ReleasePtr(MostOfIt);
  152.                                                             }
  153.                                                         ReleasePtr(MiddleInfo);
  154.                                                     }
  155.                                                 ReleasePtr(ClipString);
  156.                                             }
  157.                                         ReleasePtr(Total);
  158.                                     }
  159.                                 ReleasePtr(Concatted);
  160.                             }
  161.                         ReleasePtr(OutOf);
  162.                     }
  163.                 ReleasePtr(Clipped);
  164.             }
  165.     }
  166.  
  167.  
  168. /* present a dialog box detailing how much clamping occurred and how to fix it. */
  169. void                                    ClampWarnDialog(float Clamping, double Correction)
  170.     {
  171.         char*                                Clamped;
  172.  
  173.         Clamped = LongDoubleToString(Clamping,5,1e-4,1e6);
  174.         if (Clamped != NIL)
  175.             {
  176.                 char*                                Lead;
  177.  
  178.                 Lead = StringToBlockCopy("Some volumes were clamped.  The maximum "
  179.                     "overextent was ");
  180.                 if (Lead != NIL)
  181.                     {
  182.                         char*                                LeadPlusNum;
  183.  
  184.                         LeadPlusNum = ConcatBlockCopy(Lead,Clamped);
  185.                         if (LeadPlusNum != NIL)
  186.                             {
  187.                                 char*                                Middle;
  188.  
  189.                                 Middle = StringToBlockCopy(".  Clamping can be eliminated by "
  190.                                     "setting the inverse volume to be greater than _.");
  191.                                 if (Middle != NIL)
  192.                                     {
  193.                                         char*                                InvVol;
  194.  
  195.                                         InvVol = LongDoubleToString(Correction,5,1e-4,1e6);
  196.                                         if (InvVol != NIL)
  197.                                             {
  198.                                                 char*                                Most;
  199.  
  200.                                                 Most = ConcatBlockCopy(LeadPlusNum,Middle);
  201.                                                 if (Most != NIL)
  202.                                                     {
  203.                                                         char*                                MostNullTerm;
  204.  
  205.                                                         MostNullTerm = BlockToStringCopy(Most);
  206.                                                         if (MostNullTerm != NIL)
  207.                                                             {
  208.                                                                 char*                                InvVolNullTerm;
  209.  
  210.                                                                 InvVolNullTerm = BlockToStringCopy(InvVol);
  211.                                                                 if (InvVolNullTerm != NIL)
  212.                                                                     {
  213.                                                                         AlertInfo(MostNullTerm,InvVolNullTerm);
  214.                                                                         ReleasePtr(InvVolNullTerm);
  215.                                                                     }
  216.                                                                 ReleasePtr(MostNullTerm);
  217.                                                             }
  218.                                                         ReleasePtr(Most);
  219.                                                     }
  220.                                                 ReleasePtr(InvVol);
  221.                                             }
  222.                                         ReleasePtr(Middle);
  223.                                     }
  224.                                 ReleasePtr(LeadPlusNum);
  225.                             }
  226.                         ReleasePtr(Lead);
  227.                     }
  228.                 ReleasePtr(Clamped);
  229.             }
  230.     }
  231.